#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct test {
	int num;
	char *name;
	short date;
	char cha[2];
	short sba[4];
} *p_test;


void pointer_struct(void)
{
	struct test test;
	p_test = &test;
	printf("&test = %p\n", &test);
	printf("p_test = %p\n", p_test);
	printf("p_test + 1 = %p\n", p_test + 1);
	printf("(unsigned long)p_test + 1 = %p\n", (unsigned long)p_test + 1);
	printf("(unsigned int *)p_test + 1 = %p\n", (unsigned int *)p_test + 1);
}

void pointer_arry(void)
{

	int a[5] = {1, 2, 3, 4, 5}; //int(*p)[5]
	int *ptr1 = (int *)(&a + 1);
	int *ptr2 = (int *)((int)a + 1);

	printf("a = %p\n", a);
	printf("&a = %p\n", &a);
	printf("(int)a = %#x\n", (int)a);
	printf("(int)a + 1 = %#x\n", (int)a + 1);
	printf("(char *)((int)a + 1) = %#x\n", *(char *)((int)a + 1));
	printf("(char *)((int)a + 1) + 1 = %#x\n", *((char *)((int)a + 1) + 1));
	printf("(char *)((int)a + 1) + 2 = %#x\n", *((char *)((int)a + 1) + 2));
	printf("(char *)((int)a + 1) + 3 = %#x\n", *((char *)((int)a + 1) + 3));
	printf("(char *)((int)a + 1) = %#x\n", *((char *)((int)a + 1) + 4));
	printf("&a[0] = %p\n", &a[0]);
	printf("&a[1] = %p\n", &a[1]);
	printf("&a[2] = %p\n", &a[2]);

	printf("%#x %#x %#x %#x\n", a, (int)a, (int)a + 1, ptr2);
	printf("%#x %#x\n", ptr1[-1], *ptr2);
}

int main(void)
{
	int i = 0;
	int a[3][2] = {{0, 1}, {2, 3}, {4, 5}};
	int *p;
	p = a[0];
	printf("%d\n",i);

	return 0;
}
